package com.xucranger.ojapi.controller;


import com.xucranger.ojapi.enity.DTO.AtcoderQueryDTO;
import com.xucranger.ojapi.enity.DTO.RankDTO;
import com.xucranger.ojapi.enity.DTO.common.PageResultDTO;
import com.xucranger.ojapi.enity.DTO.common.ResponseDTO;
import com.xucranger.ojapi.enity.VO.AtcoderVO;
import com.xucranger.ojapi.enity.VO.CareeVO;
import com.xucranger.ojapi.enity.VO.RankVO;
import com.xucranger.ojapi.enity.domain.Atcoder;
import com.xucranger.ojapi.service.AtcoderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/atcoder")


public class AtcoderController {

    @Autowired
    AtcoderService atcoderService;

    //根据id查询参加比赛
    @PostMapping("/querycontestbyid")
    public ResponseDTO<PageResultDTO<AtcoderVO>> QueryContestByAcid(@RequestBody @Validated AtcoderQueryDTO queryDTO){
        return atcoderService.queryContestbyid(queryDTO);
    }

    //根据acid查询生涯
    @GetMapping("/querycareebyacid/{acid}")
    public ResponseDTO<CareeVO> QueryCareeByAcid(@PathVariable("acid") String acid){
        return atcoderService.queryCareeByAcid(acid);
    }



    //根据比赛查询学生
    @PostMapping("/querystudentbycontestname")
    public ResponseDTO<PageResultDTO<AtcoderVO>> QueryContestByContestname(@RequestBody @Validated AtcoderQueryDTO queryDTO){
        return atcoderService.queryContestbycontestname(queryDTO);
    }

    //排行榜功能
    @PostMapping("/rank")
    public ResponseDTO<PageResultDTO<RankVO>> rank(@Validated @RequestBody RankDTO rankDTO){
        return atcoderService.rank(rankDTO);
    }



}
